IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSalaryDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSalaryDetails]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO       
/************************************************************************************************        
* Name:  GetSalaryDetails                                                                        
* Purpose: Retrieving the Salary Details for the given fund number.
  NOte: The "GetProjectHeader" procedure cannot be merged on to the "GetSalariesOverview" for the reason,
		GetSalariesOverview is used in other stored procedures. Merging the above mentioned Procedures will
		proveide a different results than expected.
* PARAMETERS          
* Name   Description        
* ------------------------- -----------------------------        
* @domainUserId   Domain User Id        
* @fundId   Fund Id        
* @employeeJobMapID  Employee Job MapId        
* @endDate   the End date of the month.        
* @accountID   Account Id.        
* @categoryID   Category Id        
* ERRORS USED        
* Number   Description        
*------------------------ --------------------------------        
* n/a        
* Result Set:                                           
*-----------------------------------------------------------------------------------------------        
* Name   Description            
*-----------------------------------------------------------------------------------------------        
* n/a        
*        
* RETURN VALUE        
* Name   Description        
* ----------------------  ---------------------------        
************************************************************************************************/        
CREATE PROCEDURE [dbo].[GetSalaryDetails]        
(        
  @sessionID     VARCHAR(100)        
 ,@domainUserID     INTEGER      --1)        
 ,@includeProgramProjects  BIT = NULL     --2)        
 ,@fundNumber     VARCHAR(30) = NULL   --3)        
 ,@folderNumber     VARCHAR(16) = NULL   --4)        
 ,@bicsNumber     VARCHAR(10) = NULL   --5)        
 ,@walkerNumber     VARCHAR(10) = NULL   --6)        
 ,@sponsorNumber    VARCHAR(32) = NULL   --7)        
 ,@sponsorName     VARCHAR(64) = NULL   --8)        
 ,@sponsorTypeId    INTEGER = NULL    --9)        
 ,@agreementTypeId    INTEGER = NULL    --10)        
 ,@activityCode     VARCHAR(4)= NULL    --11)        
 ,@locationId     INTEGER = NULL    --12)        
 ,@budgetStartDate    DATETIME = NULL    --13)        
 ,@budgetEndDate    DATETIME = NULL    --14)        
    ,@projectStartDate    DATETIME = NULL    --15)        
 ,@projectEndDate    DATETIME = NULL    --16)        
 ,@piId      INTEGER = NULL    --17)        
 ,@chiefCodeList    VARCHAR(1000) = NULL  --18)        
 ,@sponsorGroupTypeId  INTEGER = NULL    --19)        
 ,@budgetEndingDays   INTEGER = NULL    --20)        
 ,@projectEndingDays   INTEGER = NULL    --21)        
 ,@fundCreatedDays     integer = NULL    --22)           
 ,@lowBalance    DECIMAL(17,2) = NULL  --23)        
 ,@highBalance    DECIMAL(17,2) = NULL  --24)        
 ,@agreementStatusTypeList  VARCHAR(50)= NULL   --25)        
 ,@fundStatusTypeId    INTEGER = NULL    --26        
 ,@CurrentDateTime   DATETIME = NULL    --27)        
 ,@firstName     VARCHAR(128) = NULL   --28)        
 ,@lastName     VARCHAR(128) = NULL   --29)        
 ,@lastGLFeedRunDate   DATETIME     --30)        
 -- Search in Salaries Overview Page        
 ,@employeeID    VARCHAR(12) = NULL   --31)        
 ,@payDateFrom    DATETIME = NULL    --32)        
 ,@payDateTo     DATETIME = NULL    --33)        
 -- Used in Salary Details Page        
 ,@incomingFundNumber  VARCHAR(30)= NULL   --34)    
 ,@cumulative int = null -- 35)
 ,@budgetYear int = null --36)
    
)        
AS        
BEGIN        
 SET NOCOUNT ON        
 BEGIN          
  EXEC dbo.GetSalariesOverview @sessionID        
							 ,@domainUserID          
							 ,@includeProgramProjects        
							 ,@fundNumber            
							 ,@folderNumber         
							 ,@bicsNumber         
							 ,@walkerNumber       
							 ,@sponsorNumber           
							 ,@sponsorName           
							 ,@sponsorTypeId      
							 ,@agreementTypeId        
							 ,@activityCode    
							 ,@locationId         
							 ,@budgetStartDate   
							 ,@budgetEndDate       
							 ,@projectStartDate      
							 ,@projectEndDate           
							 ,@piId             
							 ,@chiefCodeList       
							 ,@sponsorGroupTypeId      
							 ,@budgetEndingDays       
							 ,@projectEndingDays     
							 ,@fundCreatedDays          
							 ,@lowBalance          
							 ,@highBalance          
							 ,@agreementStatusTypeList      
							 ,@fundStatusTypeId     
							 ,@CurrentDateTime        
							 ,@firstName          
							 ,@lastName           
							 ,@lastGLFeedRunDate       
							 -- Search in Salaries Overview Page        
							 ,@employeeID         
							 ,@payDateFrom     
							 ,@payDateTo        
							 -- Used in Salary Details Page        
							 ,@incomingFundNumber 
							 ,@cumulative       
							 ,@budgetYear
 END        
 if  @incomingFundNumber is not null          
 BEGIN          
  EXEC dbo.GetProjectHeader @incomingFundNumber,NULL           
 END              
 SET NOCOUNT OFF      
END        
        
      
    
  
        
        